/*
 * @Description: app 模块
 * @Author: wangqi
 * @Date: 2024-08-15 21:24:27
 * @LastEditTime: 2024-08-25 10:41:40
 * @LastEditAuthor: wangqi
 */
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import * as dotenv from 'dotenv';
import { UserModule } from './user/user.module';
import yamConfig from './yamConfig';

/* 配置env环境选择的文件 */
const envFilePath = `.env.${process.env.NODE_ENV}`;
console.log(envFilePath, "envFilePath");

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      /* 以下模式都在 @nestjs/config 封装里实现*/
      // 读取 dotenv 模式
      envFilePath,
      load: [() => dotenv.config({ path: '.env' })],
      // 读取 config js-yaml 模式
      // load: [yamConfig],
    }),
    UserModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
